package com.silverduner.log;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * @author Yuwen Sun
 * @version 1.0
 * @deprecated development only, not a good implementation
 */
public class DefaultLogger {
	private static Log _logger;
	private static void init(){
		// HACK ALERT: retrieve the caller class by StackTrace
	    _logger = LogFactory.getLog(Thread.currentThread().getStackTrace()[3].getClass());
	}
	public static void error(Object arg0){
		init();
		_logger.error(arg0);
	}
	
	public static void error(Object arg0, Throwable arg1){
		init();
		_logger.error(arg0, arg1);
	}

	public static void warn(Object arg0){
		init();
		_logger.warn(arg0);
	}
	
	public static void warn(Object arg0, Throwable arg1){
		init();
		_logger.warn(arg0, arg1);
	}

	public static void info(Object arg0){
		init();
		if(_logger.isInfoEnabled())
			_logger.info(arg0);
	}
	
	public static void info(Object arg0, Throwable arg1){
		init();
		if(_logger.isInfoEnabled())
			_logger.warn(arg0, arg1);
	}

	public static void debug(Object arg0){
		init();
		if(_logger.isDebugEnabled())
			_logger.debug(arg0);
	}
	
	public static void debug(Object arg0, Throwable arg1){
		init();
		if(_logger.isDebugEnabled())
			_logger.debug(arg0, arg1);
	}
}
